package com.tongda.menu.widget;

import com.tongda.menu.R;

import android.content.Context;
import android.text.Editable;
import android.text.InputType;
import android.text.Selection;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class CustomEditText extends LinearLayout{


	public TextView Custv;
	public ImageView Cuspm;
	public ImageView Cuspp;
	public int num=1;
	public int maxNum;

	public CustomEditText(final Context context, AttributeSet attrs) {
		super(context, attrs);
		
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.custom_edittext,this);
		Custv = (TextView)findViewById(R.id.custom_tv);
		Custv.setText(String.valueOf(num));
		Cuspm = (ImageView)findViewById(R.id.custom_pm);
		Cuspp = (ImageView)findViewById(R.id.custom_pp);
		
		Cuspm.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(num>1){
					num--;
					Custv.setText(String.valueOf(num));
				}else{
					
				}
			}
		});
		
		Cuspp.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(num<maxNum){
					num++;
					Custv.setText(String.valueOf(num));
				}
			}
		});
	}
	 
	public void changeNum(int num){
		this.num = num;
	}
	public void changeMaxNum(int maxNum){
		this.maxNum = maxNum;
	}
}
